
package at.fhj.ase.clientarch.common.util;

/**
 * @author cja, sfe | www.fh-joanneum.at | Client Architectures and Design
 */
public final class CommonUtil {
  public static final int RMI_PORT = 7711; // should be configurable or handed over via start parameter
  public static final String CFG_KEY_TIMER_INTERVAL = "timer.interval";

  private CommonUtil() {
    throw new AssertionError("CommonUtil: Util classes are not intended/allowed to be instantiated!");
  }

  public static Object checkNullRef(final Object o) {
    if (isNull(o)) {
      throw new IllegalArgumentException("Object must not be null");
    }
    return o;
  }

  public static Object checkNullRefNamed(final Object o, final String objectName) {
    if (isNull(o)) {
      throw new IllegalArgumentException("Object " + objectName + "must not be null");
    }
    return o;
  }

  public static Object checkNullRefMethodNamed(final Object o, final String methodName, final String objectDesc) {
    if (isNull(o)) {
      throw new IllegalArgumentException("Object " + objectDesc + " must not be null in method " + methodName);
    }
    return o;
  }

  public static boolean isNull(final Object o) {
    return o == null;
  }
  
  public static boolean areNull(final Object o1, final Object o2) {
    return isNull(o1) || isNull(o2);
  }
}
